package com.muse.constant;

import lombok.Getter;

/**
 * Created with IntelliJ IDEA.
 * User: lee
 * Date: 2021/4/29
 * Time: 3:27 下午
 * Description:
 */
public enum Status {
    UNKNOWN("未知", -1),
    DOWN("下架中", 0),
    UP("上架中", 1);

    @Getter
    private String name;

    @Getter
    private int value;

    Status(String name, Integer value) {
        this.name = name;
        this.value = value;
    }

    public static Status getStatusByValue(int value) {
        for (Status type : Status.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        return UNKNOWN;
    }

    public static Status getStatusByName(String name) {
        for (Status type : Status.values()) {
            if (type.getName().equals(name)) {
                return type;
            }
        }
        return UNKNOWN;
    }
}
